<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教务管理主页查询公告</title>
    <script src="../js/axios.js"></script>
    <script src="../js/public.js"></script>
    <link rel="stylesheet" href="../css/homePage.css"/>
    <link rel="stylesheet" href="../css/homePageSelectAnn.css"/>
</head>
<body>
<div id="div">
    <div id="page_left">
        <div id=page_left_fonts>
            <span onclick="sy()">首&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;页</span>
        </div>
    </div>
    <div id="Page_right">
        <div id="Page_right_annTitle">
            <div id="Page_right_annTitle_left">

            </div>
            <div id="Page_right_annTitle_centent">

            </div>
            <div id="Page_right_annTitle_right">

            </div>
        </div>
        <div id="Page_right_annInfo">
            <!--            <div id="Page_right_annInfo_title">-->

            <!--            </div>-->
            <!--            <div id="Page_right_annInfo_date">-->

            <!--            </div>-->
            <!--            <div id="Page_right_annInfo_info">-->

            <!--            </div>-->
            <div id="Page_right_tabulation">
                <div id="Page_right_tabulation_title">
                    <span id="Page_right_tabulation_title_head">123</span>
                </div>
                <div id="Page_right_tabulation_date">
                    <span id="Page_right_tabulation_date_font">666</span>
                </div>
                <div id="Page_right_tabulation_info" style="height: 350px">
                    <span id="Page_right_tabulation_title_info">345</span>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    window.onload = function () {
        document.getElementById("div").style.height =   window.screen.availHeight - 120 + "px";

        //添加数据(一级优先)
        axios.post("http://localhost:8080/JWGLSystem/homePageServlet").then(function (resp) {
            users = resp.data;
            if (users.userName == undefined) {
                window.location.href = "../index.html";
            }

            //实现左侧菜单栏
            if (users.userPost == "管理") {
                document.getElementById("page_left_fonts").innerHTML +=
                    "            <span id='selectCourse' onclick='kccx()'>课程查询</span>\n" +
                    "            <span id='selectScore'  onclick = 'cjcx()'>成绩查询</span>\n" +
                    "            <span id='addCourse' onclick = 'kcgl()'>课程管理</span>\n" +
                    "            <span id='adTeachers' onclick = 'gljs()'>管理教师</span>\n" +
                    "            <span id='adStudents' onclick = 'glxs()'>管理学生</span>\n" +
                    "            <span id='addAnn' onclick='ggfb()'>发布公告</span>\n" +
                    "            <span id='selectAnn' onclick='ggcx()'>公告查询</span>"
            } else if (users.userPost == "学生") {
                document.getElementById("page_left_fonts").innerHTML +=
                    "            <span id='selectCourse' onclick='kccx()'>课程查询</span>\n" +
                    "            <span id='selectScore'  onclick = 'cjcx()'>成绩查询</span>\n" +
                    "            <span id='selectAnn' onclick='ggcx()'>公告查询</span>"
            } else if (users.userPost == "老师") {
                document.getElementById("page_left_fonts").innerHTML +=
                    "            <span id='selectCourse' onclick='kccx()'>课程查询</span>\n" +
                    "            <span id='selectScore'  onclick = 'cjcx()'>成绩查询</span>\n" +
                    "            <span id='addCourse' onclick = 'kcgl()'>课程管理</span>\n" +
                    "            <span id='adStudents' onclick = 'glxs()'>管理学生</span>\n" +
                    "            <span id='addAnn' onclick='ggfb()'>发布公告</span>\n" +
                    "            <span id='selectAnn' onclick='ggcx()'>公告查询</span>"
            }
        });

        //实现公告标题填充
        var id0 = document.getElementById("Page_right_annTitle_left");
        var id1 = document.getElementById("Page_right_annTitle_centent");
        var id2 = document.getElementById("Page_right_annTitle_right");
        axios.post("http://localhost:8080/JWGLSystem/homePageServletGG").then(function (resp) {
            let count = 0;
            while (count != 15) {
                var num = resp.data.length - count;
                if (count < 5) {
                    id0.innerHTML += "<p id=" + count + " onclick = select(" + count + ")>" + (count + 1) + "&nbsp;&nbsp;&nbsp;" + resp.data[num - 1].annTitle.slice(0, 15) + "...</p>";
                } else if (count < 10) {
                    id1.innerHTML += "<p id=" + count + " onclick = select(" + count + ")>" + (count + 1) + "&nbsp;&nbsp;&nbsp;" + resp.data[num - 1].annTitle.slice(0, 15) + "...</p>";
                } else if (count < 15) {
                    id2.innerHTML += "<p id=" + count + " onclick = select(" + count + ")>" + (count + 1)  + "&nbsp;&nbsp;&nbsp;" + resp.data[num - 1].annTitle.slice(0, 15) + "...</p>";
                } else {
                    console.log("break");
                    break;
                }
                count++;
            }

            document.getElementById("Page_right_tabulation_title").innerHTML = resp.data[resp.data.length - 1].annTitle;
            document.getElementById("Page_right_tabulation_info").innerHTML = resp.data[resp.data.length - 1].annContent;
            document.getElementById("Page_right_tabulation_date_font").innerHTML = "时间 " + resp.data[resp.data.length - 1].annDate;
        })
    }
</script>
</body>
</html>